Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More typescript linting #3310

Merged
merged 9 commits into from
Dec 2, 2024
Merged

More typescript linting #3310

merged 9 commits into from
Dec 2, 2024

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Apr 21, 2023

These linters identified a few incorrect types


This change is marked as an internal change (Task), so will not be included in the changelog.

@t3chguy t3chguy added the T-Task Tasks for the team like planning label Apr 21, 2023
@t3chguy t3chguy self-assigned this Aug 3, 2023
…chguy/tslint

# Conflicts:
#	.eslintrc.cjs
#	src/autodiscovery.ts
#	src/crypto/RoomList.ts
#	src/crypto/crypto.ts
#	src/models/MSC3089TreeSpace.ts
#	src/secret-storage.ts
Signed-off-by: Michael Telatynski <[email protected]>
Signed-off-by: Michael Telatynski <[email protected]>
Comment on lines 481 to +486
public getUserId(): string {
return this.userId;
}
public getSafeUserId(): string {
return this.userId;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the save version of this of getUserId already returns a non optional?
What is the difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a stub for MatrixClient, getUserId actually returns string | null
image

The code under test was changed to use getSafeUserId to avoid getting null and thus the test must also make this method available so it doesn't end up throwing an exception

const localMember = this.room.getMember(this.client.getUserId()!)!;
const localMember = this.room.getMember(this.client.getSafeUserId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it seems to be fine to just remove the exclamation mark but keep the getUserId method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as getUserId has return type string | null in reality, the test stub is misleading

@t3chguy t3chguy requested a review from toger5 December 2, 2024 09:45
@t3chguy t3chguy added this pull request to the merge queue Dec 2, 2024
Merged via the queue into develop with commit 8863e42 Dec 2, 2024
28 checks passed
@t3chguy t3chguy deleted the t3chguy/tslint branch December 2, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants